var webpack = require('webpack');
var path = require('path');

module.exports = {
    context: __dirname + '/src',
    entry:
        {
            index: './js/index.js',
            vendor: [
                'react',
                'react-dom'
            ]
        },
    mode: 'development',
    module: {
        rules: [
            {
                test: /\.js?$/,
                exclude: /(node_modules)/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015', 'stage-0']
                }
            }, {
                test: /\.css$/,
                loader: 'style-loader!css-loader'
            },
        ]
    },
    output: {
        path: __dirname + "/dist/",
        filename: '[name].js'
    },

    devServer: {
        //contentBase: "./src", //本地服务器所加载的页面所在的目录
        historyApiFallback: true, //不跳转
        inline: true  //实时刷新
    },
    optimization: {
        splitChunks: {
            cacheGroups: {
                commons: {
                    name: "commons",
                    chunks: "initial",
                    minChunks: 2
                }
            }
        }
    }
}
